#include"../../include/Configuration.h"
#include<fstream>
#include<sstream>
#include<iostream>
using namespace std;

Configuration::Configuration(const string &filePath)
:_filePath(filePath)
{

}

map<string,string> Configuration::getConfigMap()
{
    fstream fread(_filePath,ios::in);
    string lines;
    while(getline(fread,lines))
    {
        stringstream ss;
        ss<<lines;
        int cnt = 2;
        pair<string,string> par;
        while(getline(fread,lines))
        {
            stringstream ss;
            ss<<lines;

            pair<string,string> par;
            ss>>par.first>>par.second;
            cout<<par.first<<" "<<par.second<<endl;
            _configMap.insert(par);
        }
        fread.close();
        return _configMap;
    }
}
set<string> &Configuration::getStopWordList()
{
    fstream fread(_filePath,ios::in);
    string lines;
    while(getline(fread,lines))
    {
        stringstream ss;
        ss<<lines;
        while(ss)
        {
            string word;
            ss>>word;
            if(word.size()>0 && word!="\n")
            {
                _stopWordList.insert(word);                
            }
        }
    }
    fread.close();
    return _stopWordList;
}

void Configuration::printStopWord()
{
    for(auto s:_stopWordList)
    {
        cout<<s<<endl;
    }

}

void Configuration::printConfigMap()
{
    for(auto par:_configMap)
    {
        cout<<par.first<<" "<<par.second<<endl;       
    }
}
